#ifndef STACK_H_
#define STACK_H_

#include <cstddef>

namespace lxj
{

template<class T, size_t Num = 0>
class Stack {
    static_assert(Num <= 4096, "容量最大为4096");

    T            alloc[Num] = {};
    unsigned int _l, _r;

public:
    Stack() : _l(0), _r(0) {}

    T top() const noexcept
    {
        static_assert(Num > 0, "请设置容量");
        auto i = _r == 0 ? 0 : _r - 1;
        return alloc[i];
    }

    unsigned short size() const { return _r - _l; }

    void pop()
    {
        static_assert(Num > 0, "请设置容量");
        _r == 0 ? _r : _r--;
    }

    void push(int value)
    {
        static_assert(Num > 0, "请设置容量");
        if (_r >= Num) return;
        alloc[_r] = value;
        _r++;
    }
};
}   // namespace lxj

#endif